<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>登录</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/member.css"/>
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>
    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
</head>

<body>
<div id="header">
    <header class="header" style="border-bottom: none;">
        <!--<div class="header-left">-->
            <!--<div tapmode onclick="comeBack();" class="nav-left"><img class="icon-back" src="../../icon/icon-back.png"/>-->
            <!--</div>-->
        <!--</div>-->
        <!-- <div class="header-right">
            <div  tapmode onclick="commonUrl('register')" class="nav-right">注册</div>
        </div> -->
    </header>
</div>

<section class="html_section  pr30 pl30 login_section">
    <!-- <div class="login_title b"><span>请输入账号密码</span></div> -->
    <div class="line_center flex_center"><img class="logon_logo" src="../../icon/logo_login.png"/></div>
    <div class="line_center flex_center f32 mt20">大学情报局</div>
    <div class="line_center flex_center f26 c-999">助力你的大学生活</div>
    <div style="margin-top:0.5rem" class="f26">
        <div class="line_center"><input class="login_input" id="mobile" placeholder="请输入您的手机号"/></div>
        <div class="line_center login_input_box"><input class="login_input" id="password" placeholder="请输入密码" type="password"/>
            <div class="eyes"></div>
        </div>
    </div>

    <div tapmode class="btn1 mt60 f30" onclick="login()">登录</div>
    <div tapmode class="btn2 mt30 f30" onclick="commonUrl('login')">短信验证码登录</div>
    <div class="flex_end mt10">
        <div class="c-primary f22" tapmode onclick="commonUrl('forget')">忘记密码?</div>
    </div>
    <div class="lines c-999 f22 threeLogin" style="display: none;"><span class="ml20 mr20">第三方快捷登录</span></div>
    <ul class="three threeLogin" style="display: none;">
        <li tapmode class="qq" id="qqLogin"><img src="../../icon/three-qq.png"/></li>
        <li tapmode class="wb" id="wbLogin"><img src="../../icon/three-wb.png"/></li>
        <li tapmode class="wx" id="wxLogin"><img src="../../icon/three-wx.png"/></li>
    </ul>
</section>


<section class="mask_pop">
    <div class="mask"></div>
    <div class="msg_pop2 pop pb20" style="display: none; max-width: calc(100% - 1.8rem);">
        <div class="msg_pop_title">权限请求</div>
        <div class="msg_pop_content" style="text-align: left; padding: 0 0.3rem 0.4rem;">"大学情报局"请求通知栏通知消息权限，是否允许？<br>
            <span class="f22">若是，可能会跳转到权限设置里进行设置；<br>若否，该权限也可在手机设置中的权限管理里更改权限配置</span></div>
        <div class="flex_center pb20">
            <div class="btn7 mr30" onclick="popClose();">取消</div>
            <div class="btn6" onclick="popClose(1);">允许</div>
        </div>
    </div>
</section>
</body>

</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
    var close = '';
    apiready = function () {
        setFixStatusBar(); //设置状态栏

        close = api.pageParam.close;

        checkSystemType(function () {
            checked_three();
        },function () {

        })

        var phone = $api.getStorage('phone');
        console.log(phone)
        if(isDefine(phone)){
            $("#mobile").val(phone)
        }

        isGetPermissions()

        SystemCheckVersion()

        if (isDefine(close)){
            api.closeWin({
                name: 'setting'
            });
        }
        ExitApp();

        api.closeWin({
            name: 'guide'
        });



    }


    function openApp() {
        $(".mask").show();
        $(".mask_pop").addClass("on");
        $(".msg_pop2").show();
    }

    function popClose(status) {
        $(".mask").hide();
        $(".mask_pop").removeClass("on");
        if(status){
            //获取存储权限
            var resultList3 = api.hasPermission({
                list: ['notification']
            });

            if (resultList3[0].granted) {
            } else {
                api.requestPermission({
                    list: ['notification'],
                    code: 3
                }, function(ret, err) {

                });
            }
        }

    }


    $(".eyes").click(function () {
        if ($(this).hasClass("on")) {
            $(this).removeClass("on");
            $(this).prev().attr("type", "password");
        } else {
            $(this).addClass("on");
            $(this).prev().attr("type", "text");
        }
    })

    //提交 - 登录
    function login() {
        $(".login_input").blur();
        var param = {
            type: 2, //类型：1手机号登录 2密码登录
            key: $("#mobile").val(),
            password: $("#password").val(),
            device_id: api.deviceId
        };
        if (param.key == "") {
            pop.notice('请输入您的手机号');
            return
        }
        if (param.password == "") {
            pop.notice('请输入密码');
            return
        }
        pop.loading();
        getAjax(Interface.login, param, function (res) {
            console.log(res);
            $api.setStorage('phone', $("#mobile").val());
            $api.setStorage('token', res.token);
            $api.setStorage('userInfo', res.data);
            if(isDefine(res.data.school_path)){
                $('#school_path').attr('src', ajaxUrl + res.data.school_path);
                $api.setStorage('schoolPath', ajaxUrl + res.data.school_path);
                $api.setStorage('schoolPath_status', 1);
                api.sendEvent({
                    name: 'schoolPathStatus',
                });
            }else {
                $('#school_path').attr('src', '../../icon/logo.png');
                $api.setStorage('schoolPath', '../../icon/logo.png');
                $api.setStorage('schoolPath_status', 2);
                api.sendEvent({
                    name: 'schoolPathStatus',
                });
            }
            $api.setStorage('newLogin', 1);
            pop.close();
            if (res.data.status == 2) {
                commonUrl('perfect')
            } else {
                individualUrl('../index/index')
            }

        }, function (ret, err) {
            pop.close();
            pop.notice(ret.msg);
        })
    }



    //微信
    $("#wxLogin").click(function(){
        wxLogin(function(ret){
            var p = {outher_id:ret.unionid,type:1}
            threeLogin(p);
        })
    })
    //Qq
    $("#qqLogin").click(function(){
        QQLogin(function(ret){
            var p = {outher_id:ret.openId,type:2}
            threeLogin(p);
        })
    })
    //微博
    $("#wbLogin").click(function(){
        WeiBoLogin(function(ret){
            var p = {outher_id:ret.userId,type:3}
            threeLogin(p);
        })
    })
    function threeLogin(p){
        getAjax(Interface.other_login,p,function(res){
            pop.close();
            if(res.token){
                $api.setStorage('token', res.token);
                $api.setStorage('userInfo', res.data);
                if(isDefine(res.data.school_path)){
                    $('#school_path').attr('src', ajaxUrl + res.data.school_path);
                    $api.setStorage('schoolPath', ajaxUrl + res.data.school_path);
                    $api.setStorage('schoolPath_status', 1);
                }else {
                    $('#school_path').attr('src', '../../icon/logo.png');
                    $api.setStorage('schoolPath', '../../icon/logo.png');
                    $api.setStorage('schoolPath_status', 2);
                }
                pop.close();
                if (res.data.status == 2) {
                    commonUrl('perfect');
                } else {
                    individualUrl('../index/index');
                }
            }else{
                commonUrl('bang_tel',p);
            }
        },function(res,err){

        })
    }





</script>
